﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace AbstractFactory.Factory
{
    public abstract class Page
    {
        protected string title;
        protected string author;
        protected List<Item> content;

        public Page(string title, string author)
        {
            this.content = new List<Item>();
            this.title = title;
            this.author = author;
        }

        public void Add(Item item)
        {
            content.Add(item);
        }

        public void Output()
        {
            try
            {
                string fileName = title + ".html";

                using (var write = new StreamWriter(fileName, false, Encoding.Default))
                {
                    write.Write(this.MakeHTML());
                }

                Console.WriteLine(fileName + " を作成しました。");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }

        public abstract string MakeHTML();
    }
}
